package option;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Add implements Ioperate{

    //尾插
    @Override
    public void work(BookList bookList) {

        int i = bookList.getCurSize();
        if(i == bookList.getCount()){
            System.out.println("书架已满，无法增加.....");
        }else {
            Scanner scan = new Scanner(System.in);
            System.out.println("请输入你要增加的图书名字：");
            String bookName = scan.nextLine();

            System.out.println("请输入作者名：");
            String author = scan.nextLine();

            System.out.println("请输入书本的价格：");
            double price = scan.nextDouble();

            Book book = new Book(bookName,author,price);
            bookList.setBooks(i, book);

            bookList.setCurSize(i+1);
        }
    }
}
